obs = obslua

local delay = 10 -- 延迟时间，单位为秒
local timer_active = false

function script_description()
    return "延迟启动录制。设置10秒后开始录制。"
end

function start_recording()
    obs.obs_frontend_recording_start()
    timer_active = false
    obs.remove_current_callback()
end

function trigger_delay_recording()
    if not timer_active then
        obs.timer_add(start_recording, delay * 1000)
        timer_active = true
    end
end

function script_properties()
    local props = obs.obs_properties_create()
    obs.obs_properties_add_button(props, "start_delay_recording", "延迟启动录制", trigger_delay_recording)
    return props
end
